package com.searchtree.main;

import com.searchtree.main.Performance;

public class Utilities
{
	static Performance performance = Performance.getInstance();
	/**
	 * Compares the alphabetical order of two strings
	 * 
	 * @param n
	 * @return -1 if left < right
	 * 			0 if left = right
	 * 			1 if left > right
	 */
	public static int compareStringValues(String left, String right) 
	{
		performance.addToNumberOfCompares(1);
		for (int i = 0; i < Math.min(left.length(), right.length()); i++) 
		{
			if (Character.getNumericValue(left.charAt(i)) > Character.getNumericValue(right.charAt(i)))
			{
				return 1;
			}
			else if (Character.getNumericValue(left.charAt(i)) < Character.getNumericValue(right.charAt(i)))
			{
				return -1;
			}
		}
		if (left.length() < right.length())
		{
			return -1;
		}
		else if (left.length() > right.length())
		{
			return 1;
		}
		else
		{
			return 0;
		}
	}
}
